package HTMLCrators;
import java.io.*;

public class HTMLCreatorFromFile implements HTMLCreator{
	
	private BufferedReader buff;
	private String nextLine;
	private FileReader reader;
	
	public HTMLCreatorFromFile(String fileName) throws IOException{
		reader=new FileReader(new File(fileName));
		buff=new BufferedReader(reader);
	}

	protected String editLine(String line){
		return line;
	}
	
	public boolean haveMoreLines() {
		return nextLine!=null;
	}

	public String nextLine() {
		try {
			String thisLine=nextLine;
			nextLine=buff.readLine();
			if (nextLine!=null)
				nextLine=editLine(nextLine);
			return thisLine;
		} catch (IOException e) {
			return null;
		}
	}

	public void finish() {		
		try {
			reader.close();
			buff.close();
		} catch (IOException e) {
			//TODO
		}
	}

	public void init() {
		try {
			nextLine=buff.readLine();
			if (nextLine!=null)
				nextLine=editLine(nextLine);
		} catch (IOException e) {
			nextLine=null;
		}
	}
	
	
}
